import axiosServer from "@/utils/request";

/**
 * Add Announcement
 * @param {string} notice Name
 * @param {string} noticeTime Time
 * @param {string} content Content
 * @param {number} type 1: Normal, 2: Scroll, 3: Popup
 */
export const userLogin = (username, password) => {
    return axiosServer({
        method: "post",
        url: "/login/admin",
        params: { username, password }
    });
};

/**
 * Query User Funds
 * @param {number} userId User ID
 * @param {string} username Username
 * @param {string} roleName Role Name
 * @param {number} page Page number
 * @param {number} limit Limit per page
 * @returns 
 */
export const userListMoney = (userId, username, roleName, page, limit) => {
    return axiosServer({
        method: "get",
        url: "/fund/listData",
        params: { userId, username, roleName, page, limit }
    });
};

/**
 * Restrict Login Interface
 * @param {string} theSecretKey Secret Key
 * @returns 
 */
export const nologin = (theSecretKey) => {
    return axiosServer({
        method: "post",
        url: "/login/forcedOffline",
        params: { theSecretKey }
    });
};

/**
 * Release Login Restriction Interface
 * @param {string} theSecretKey Secret Key
 * @returns 
 */
export const islogin = (theSecretKey) => {
    return axiosServer({
        method: "post",
        url: "/login/recovery",
        params: { theSecretKey }
    });
};

/**
 * Dark Room List
 * @param {number} page Page
 * @param {number} limit Limit
 * @returns 
 */
export const DarkList = (page, limit) => {
    return axiosServer({
        method: "get",
        url: "/accounts/loadByBanned",
        params: { page, limit }
    });
};

/**
 * Modify Ban Reason
 * @param {number} id ID
 * @param {string} banreason Ban Reason
 * @returns 
 */
export const changeDarkMsg = (id, banreason) => {
    return axiosServer({
        method: "post",
        url: "/accounts/updateBanned",
        params: { id, banreason }
    });
};

/**
 * Modify Display Status
 * @param {number} id ID
 * @param {boolean} display Display Status
 * @returns 
 */
export const changeDarkDisplay = (id, display) => {
    return axiosServer({
        method: "post",
        url: "/accounts/updateDisplay",
        params: { id, display }
    });
};

/**
 * Money Dictionary - Query All
 * @returns 
 */
export const moneyDictionary = () => {
    return axiosServer({
        method: "get",
        url: "/currency/loadAll",
    });
};

/**
 * Query User Fund Details
 * @param {number} page Page number
 * @param {number} limit Limit per page
 * @param {number} userId User ID
 * @param {string} username Username
 * @returns 
 */
export const moneyDetail = (page, limit, userId, username) => {
    return axiosServer({
        method: "get",
        url: "/fundDetails/listData",
        params: { page, limit, userId, username }
    });
};

/**
 * Refund User Fund Details
 * @param {number} page Page number
 * @param {number} limit Limit per page
 * @param {number} userId User ID
 * @param {string} username Username
 * @returns 
 */
export const moneyRefund = (page, limit, userId, username) => {
    return axiosServer({
        method: "get",
        url: "/FundReturn/listData",
        params: { page, limit, userId, username }
    });
};

/**
 * Unban Player
 * @param {number} id ID
 * @returns 
 */
export const unbanPlayer = (id) => {
    return axiosServer({
        method: "post",
        url: "/accounts/updateBan", // Unban
        params: { id }
    });
};